#pragma once

#include <boost/ptr_container/ptr_vector.hpp>

#include "win_exports.hpp"
#include "Widget.hpp"




namespace WinUi
{
	class WINUI_API Window : public Widget
	{
	public:

		typedef boost::signals2::signal<bool(),boostext::negative_combiner>   decision;

	protected:

		boost::ptr_vector<Widget>   m_widgets;

		/// Emitted when the window has been moved
		notification   m_moved;

		/// Emitted when the window has been resized
		notification   m_resized;

		/// Emitted when the window shall be closed
		decision        m_closing;

		/// This signal is emitted whenever the window is activated
		notification   m_activated;

		/// This signal is emitted whenever the window is deactivated
		notification   m_deactivated;

	public:

		boostext::connector<notification>   moved;
		boostext::connector<notification>   resized;
		boostext::connector<decision>       closing;
		boostext::connector<notification>   activated;
		boostext::connector<notification>   deactivated;

	public:

		/**
		 * Create a Window.
		 * A window is really a window on the screen (ie. no control)
		 * that implements more behaviour and signals than Widget does.
		 *
		 * @param parent        the parent of the widget
		 * @param className     the name of the window class, that will be registered with windows
		 * @param pos           the position of the widget, relative to the upper left corner of the parent
		 * @param size          the size of the widget, in pixels
		 * @param [opt] style   the style for the widget
		 */
		Window(Window* parent, const std::wstring& className, int2 pos, int2 size, int style = 0);
		virtual ~Window();



		/**
		 * Add a widget to this window.
		 * This window takes ownership of the widget and
		 * deletes it, when necessary.
		 */
		void add(Widget* widget);



		/**
		 * Find out if this window is minimized.
		 */
		bool minimized() const;



		/**
		 * Show this window in it's normal state.
		 */
		void showNormal();

		/**
		 * Show this window in it's maximized state (ie. in the taskbar).
		 */
		void showMaximized();

		/**
		 * Show this window in it's minimized state.
		 */
		void showMinimized();

		/**
		 * Makes this window the top one (bring it to the front).
		 */
		void toTop();

		/**
		 * Make this window the bottom one (bring it to the back).
		 */
		void toBottom();



		/**
		 * Show the mouse cursor.
		 */
		static void showCursor(bool show = true);

		/**
		 * Hide the mouse cursor.
		 */
		static void hideCursor(bool hide = true);

	protected:

		LRESULT msgProc(UINT msg, WPARAM wParam, LPARAM lParam);
	};
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
